<div class="am-g">
    <!-- Row start -->
    <div class="am-u-sm-12">
        <div class="card-box">
            <form action="" class="am-form"  data-am-validator id="doc-vld-msg">
                <fieldset>
                    <legend>添加用户</legend>
                    <div class="am-form-group am-form-group-sm">
                        <label for="doc-vld-name-2">分类名称：</label>
                        <input type="text" name="name" value="{{.Sdata.Pid}}" class="am-form-field" id="fname" placeholder="分类名称"/>
                    </div>
                    <div class="am-form-group">
                        <div class="am-g">
                            <label class="am-u-md-2 am-md-text-right" for="doc-select-1">父级分类</label>
                            <select id="doc-select-1" name="pid" id="pids">
                                <option value="0">主分类</option>
                                {{range .ol}}
                                <option value="{{.Id}}" {{if eq .Id .Sdata.Pid}} selected="selected" {{end}}>{{.Name}}</option>
                                {{end}}
                            </select>
                            <span class="am-form-caret"></span>
                        </div>					      
                    </div>
                    <button class="am-btn am-btn-secondary" type="button">提交</button>
                </fieldset>
            </form>


        </div>
    </div>
    <!-- Row end -->
</div>
</div>
</div>
<script>
    var _url="sorts/add"
    $(".am-btn").on("click",function(){
        var name=$("#fname").val();
        var pid =$("#pids").val();
        if(name.length<1){
            alert("分类名称不能为空！")
            return
        }
        $.post(_url,{name:name,pid:pid},function(data){
            if(data.status==1){
                alert("添加成功")
                window.location.href=data.url
            }else{
                alert(data.msg);
            }
        },"json");
    });
</script>